package pack1;

public class Program7 {
	public static void main(String args[])
	{
		String fn="rajendra";
		String sn="sharma";
		int m = fn.length();
		int n=sn.length();
		char a[]=new char[m];
		char b[]=new char[n];
		
		//inserting fn into array
		for(int i=0;i<fn.length();i++)
		{
			a[i]=fn.charAt(i);
		}
		//displaying array a[]
		for(int i=0;i<fn.length();i++)
		{
			System.out.println(a[i]);
		}
		System.out.println("------------------------");
		//inserting sn into array
				for(int i=0;i<sn.length();i++)
				{
					b[i]=sn.charAt(i);
				}
				//displaying array a[]
				for(int i=0;i<sn.length();i++)
				{
					System.out.println(b[i]);
				}
			System.out.println("-----------------------");
			int count=0;
			//finding number of same characters in strings
			for(int i=0;i<m;i++)
			{
				for(int j=0;j<n;j++)
				{
					if(a[i]==b[j])
					{
						count++;
						
					}
				}
			}
			char c[]=new char[count];	
			//storing similar characters into array c 
			int count1=-1;
			for(int i=0;i<m;i++)
			{
				for(int j=0;j<n;j++)
				{
					if(a[i]==b[j])
					{
						//System.out.println(c.length);
						for(int k=0;k<=c.length;k++)
						{
						if(c[k]!=a[i])
						{
							++count1;
							
						c[count1]=a[i];
						}
						}
					}
				}
			}
			System.out.println("similar characters are");
			for(int i=0;i<count;i++)
			{
				System.out.println(c[i]);
			}
				
	}

}
